home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000…tember: Reference Library / Dev.CD Sep 00 RL Disk 1.toast / mac / Technical Documentation / Develop / develop Issue 27 / develop Issue 27 code / Internet Config Assistant / toolkit / CPoint.cp < prev    next >
Encoding:
Text File  |  1996-04-07  |  925 b   |  61 lines  |  [TEXT/CWIE]

  1.  
  2. #include "CPoint.h"
  3.  
  4. #include "CRect.h"
  5.  
  6. void CPoint::ConstrainTo(const CRect& rect)
  7. {
  8.     if (X() > rect.Right())
  9.         fPoint.h = rect.Right();
  10.     else if (X() < rect.Left())
  11.         fPoint.h = rect.Left();
  12.     
  13.     if (Y() > rect.Bottom())
  14.         fPoint.v = rect.Bottom();
  15.     else if (Y() < rect.Top())
  16.         fPoint.v = rect.Top();
  17. }
  18.  
  19.  
  20. CPoint CPoint::operator+(const CPoint& pt) const
  21. {
  22.     return CPoint(X() + pt.X(), Y() + pt.Y());
  23. }
  24.  
  25.  
  26. CPoint CPoint::operator-(const CPoint& pt) const
  27. {
  28.     return CPoint(X() - pt.X(), Y() - pt.Y());
  29. }
  30.  
  31.  
  32. CPoint& CPoint::operator+=(const CPoint& pt)
  33. {
  34.     fPoint.h += pt.X();
  35.     fPoint.v += pt.Y();
  36.     return *this;
  37. }
  38.  
  39.  
  40. CPoint& CPoint::operator-=(const CPoint& pt)
  41. {
  42.     fPoint.h -= pt.X();
  43.     fPoint.v -= pt.Y();
  44.     return *this;
  45. }
  46.  
  47.  
  48.  
  49. Boolean CPoint::operator!=(const CPoint& pt) const
  50. {
  51.     return (X() != pt.X()) || (Y() != pt.Y());
  52. }
  53.  
  54.  
  55. Boolean CPoint::operator==(const CPoint& pt) const
  56. {
  57.     return (X() == pt.X()) && (Y() == pt.Y());
  58. }
  59.  
  60.  
  61.